package cn.doitedu.day07

import org.apache.spark.sql.{DataFrame, SparkSession}

object T10_CreateDataFrameFromJson {

  def main(args: Array[String]): Unit = {

    val spark = SparkSession.builder().appName(this.getClass.getSimpleName)
      .master("local[4]")
      .getOrCreate()

    //sparksql支持统一的数据访问方式
    val df: DataFrame = spark.read.json("data/order.json")

    //df.printSchema()
    //df.show(50)

    //注册试图
    df.createTempView("v_order")

    val df2 = spark.sql("select cid, dt, money, oid, province from v_order where _corrupt_record is null")

    df2.show()

    //Thread.sleep(1000000)

  }

}
